﻿<!--
Copyright © 2010 François Karman

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

See <license.txt> for the complete license of the software.
-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Faz.Dependencies.Controls">

    <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type local:LinkView}, ResourceId=ItemContainerDefaultStyleKey}"
           TargetType="{x:Type ListViewItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListViewItem}">
                    <ContentControl Margin="10">
                        <Border AllowDrop="{TemplateBinding AllowDrop}"
                                Background="{TemplateBinding Background}"
                                BindingGroup="{TemplateBinding BindingGroup}"
                                BitmapEffect="{TemplateBinding BitmapEffect}"
                                BitmapEffectInput="{TemplateBinding BitmapEffectInput}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CacheMode="{TemplateBinding CacheMode}"
                                Clip="{TemplateBinding Clip}"
                                ClipToBounds="{TemplateBinding ClipToBounds}"
                                ContextMenu="{TemplateBinding ContextMenu}"
                                Cursor="{TemplateBinding Cursor}"
                                Effect="{TemplateBinding Effect}"
                                FlowDirection="{TemplateBinding FlowDirection}"
                                Focusable="{TemplateBinding Focusable}"
                                FocusVisualStyle="{TemplateBinding FocusVisualStyle}"
                                ForceCursor="{TemplateBinding ForceCursor}"
                                Height="{TemplateBinding Height}"
                                HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                                LayoutTransform="{TemplateBinding LayoutTransform}"
                                Margin="{TemplateBinding Margin}"
                                MaxHeight="{TemplateBinding MaxHeight}"
                                MaxWidth="{TemplateBinding MaxWidth}"
                                MinHeight="{TemplateBinding MinHeight}"
                                MinWidth="{TemplateBinding MinWidth}"
                                Opacity="{TemplateBinding Opacity}"
                                OpacityMask="{TemplateBinding OpacityMask}"
                                Padding="{TemplateBinding Padding}"
                                RenderTransform="{TemplateBinding RenderTransform}"
                                RenderTransformOrigin="{TemplateBinding RenderTransformOrigin}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                ToolTip="{TemplateBinding ToolTip}"
                                UseLayoutRounding="{TemplateBinding UseLayoutRounding}"
                                VerticalAlignment="{TemplateBinding VerticalAlignment}"
                                Visibility="{TemplateBinding Visibility}"
                                Width="{TemplateBinding Width}">
                            <ContentPresenter ContentSource="Content"
                                              HorizontalAlignment="Stretch"
                                              VerticalAlignment="Stretch" />
                        </Border>
                    </ContentControl>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type local:LinkView}, ResourceId=DefaultStyleKey}"
           TargetType="{x:Type ListView}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListView}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <ItemsControl ItemsSource="{Binding ElementName=result, Path=Connectors}">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <Canvas IsItemsHost="True" />
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                            <local:LinkViewResult x:Name="result"
                                                  IsItemsHost="True" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:LinkViewConnector}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:LinkViewConnector}">
                    <Canvas>
                        <Path Stroke="Black"
                              StrokeThickness="1"
                              SnapsToDevicePixels="True"
                              Data="{TemplateBinding Geometry}" />
                        <Control Canvas.Top="{Binding Path=StartPoint.Y, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                 Canvas.Left="{Binding Path=StartPoint.X, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                 Width="10"
                                 Height="10"
                                 Template="{Binding Path=LinkView.LineStartTemplate, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                            <Control.RenderTransform>
                                <TransformGroup>
                                    <TranslateTransform X="-5"
                                                        Y="-5" />
                                    <RotateTransform Angle="{Binding Path=StartPointAngle, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                                </TransformGroup>
                            </Control.RenderTransform>
                        </Control>
                        <Control Canvas.Top="{Binding Path=EndPoint.Y, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                 Canvas.Left="{Binding Path=EndPoint.X, RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                 Width="10"
                                 Height="10"
                                 Template="{Binding Path=LinkView.LineEndTemplate, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                            <Control.RenderTransform>
                                <TransformGroup>
                                    <TranslateTransform X="-5"
                                                        Y="-5" />
                                    <RotateTransform Angle="{Binding Path=EndPointAngle, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                                </TransformGroup>
                            </Control.RenderTransform>
                        </Control>
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
